﻿package mortal.game.view.guildWar
{
    import Message.Public.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.component.window.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.item.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class GuildWarResultWindowNew2 extends ResultBaseWindow
    {
        private var _totalExploit:GuildWarResultCellNew;
        private var _totalResource:GuildWarResultCellNew;
        private var _totalContribute:GuildWarResultCellNew;
        private var _tfExtraExploitTips:GTextFiled;
        private var _loseTxt:GImageBitmap;
        private var _loseLine:ScaleBitmap;
        private var _itemCode:int = 120221349;
        private var _itemWinTxt:GImageBitmap;
        private var _itemBg:GImageBitmap;
        private var _item:BaseItem;
        private var _result:SGuildWarResult;
        public static var _instance:GuildWarResultWindowNew2;

        public function GuildWarResultWindowNew2(param1:ILayer = null)
        {
            super(param1);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            setContentBgSize(340, 130);
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.guildWarResultBgNew2, 239, 45, this));
            this._totalExploit = UIFactory.getUICompoment(GuildWarResultCellNew, 210, 100, this);
            this._totalResource = UIFactory.getUICompoment(GuildWarResultCellNew, 210, 137, this);
            this._totalContribute = UIFactory.getUICompoment(GuildWarResultCellNew, 210, 174, this);
            this._tfExtraExploitTips = UIFactory.gTextField(Language.getStringByParam(11448, "1000", "300"), 214, 200, 300, 25, this, GlobalStyle.textFormatHuang2.setSize(14).setBold(true), true);
            this._tfExtraExploitTips.visible = false;
            this._loseLine = UIFactory.bg(185, 185, 330, 2, this, ImagesConst.SplitLine);
            this._loseTxt = UIFactory.gImageBitmap(ImagesConst.guildWarResultNew2Lose, 272, 197, this);
            this._itemBg = UIFactory.gImageBitmap(ImagesConst.guildWarResultNew2ItemBg, 394, 80, this);
            this._itemWinTxt = UIFactory.gImageBitmap(ImagesConst.guildWarResultNew2WinTxt, 398, 96, this);
            this._item = UIFactory.baseItem(410, 126, 64, 64, this);
            this._item.isShowColorBg = false;
            this._item.itemData = new ItemData(this._itemCode);
            this._loseLine.visible = false;
            this._loseTxt.visible = false;
            this.setContentBgSize(375, 166);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._loseLine.dispose(param1);
            this._loseLine = null;
            this._loseTxt.dispose(param1);
            this._loseTxt = null;
            this._itemBg.dispose(param1);
            this._itemBg = null;
            this._item.dispose(param1);
            this._item = null;
            this._itemWinTxt.dispose(param1);
            this._itemWinTxt = null;
            this._totalExploit.dispose(param1);
            this._totalExploit = null;
            this._totalResource.dispose(param1);
            this._totalResource = null;
            this._totalContribute.dispose(param1);
            this._totalContribute = null;
            this._tfExtraExploitTips.dispose(param1);
            this._tfExtraExploitTips = null;
            this._result = null;
            super.disposeImpl(param1);
            return;
        }// end function

        public function updateResult(param1:SGuildWarResult) : void
        {
            this._result = param1;
            var _loc_2:* = this._result.nowScore - this._result.formerScore >= 0 ? ("+") : ("");
            this._totalResource.updateData(ImagesConst.guildWarResultNew2ResourceTxt, "+" + this._result.baseResource.toString());
            this._totalExploit.updateData(ImagesConst.guildWarResultNew2ExploitTxt, "+" + this._result.baseExploit.toString());
            this._totalContribute.updateData(ImagesConst.guildWarResultNew2ContributeTxt, "+" + this._result.baseContribute.toString());
            this._loseLine.visible = !this._result.isWin;
            this._loseTxt.visible = !this._result.isWin;
            this._itemBg.visible = this._result.isWin;
            this._item.visible = this._result.isWin;
            this._itemWinTxt.visible = this._result.isWin;
            this._tfExtraExploitTips.visible = this._result.isWin;
            if (this._result.isWin)
            {
                this._totalExploit.y = 95;
                this._totalResource.y = 132;
                this._totalContribute.y = 169;
                this._tfExtraExploitTips.htmlText = Language.getStringByParam(11448, this._result.anotherScore.toString(), this._result.extraExploit.toString());
                this._tfExtraExploitTips.visible = this._result.extraExploit > 0;
            }
            else
            {
                this._totalExploit.x = 284;
                this._totalResource.x = 284;
                this._totalContribute.x = 284;
                this._totalExploit.y = 95;
                this._totalResource.y = 122;
                this._totalContribute.y = 149;
            }
            if (this._result.isWin)
            {
                resultType = ResultBaseWindow.showSuccess;
            }
            else
            {
                resultType = ResultBaseWindow.showFail;
            }
            return;
        }// end function

        override protected function enterBtnClickHandler(event:MouseEvent) : void
        {
            if (this._result && this._result.isWin)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.GuildWarGetWinGift));
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.CopyLeave));
            this.hide();
            return;
        }// end function

        override protected function updateSize() : void
        {
            super.updateSize();
            if (_enterBtn)
            {
                _enterBtn.x = (this.width - _enterBtn.width) * 0.5;
                _enterBtn.y = this.height - _enterBtn.height - 80;
            }
            return;
        }// end function

        public static function get instance() : GuildWarResultWindowNew2
        {
            if (!_instance)
            {
                _instance = new GuildWarResultWindowNew2;
            }
            return _instance;
        }// end function

    }
}
